/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unc.pds.facets;

import unc.pds.filemodel.PhotoRemote;

/**
 *
 * @author Mikhail
 */
public class PhotoFacet implements Facet {
    private PhotoRemote photo;
    private boolean isOwn;
    public PhotoFacet(PhotoRemote photo, boolean isOwn) {
        this.photo = photo;
        this.isOwn = isOwn;
    }
    public String draw() throws Exception {
        String result = "";
        result += "<p><h4>"+photo.getName()+" - "+photo.getAuthor().getNickname()+"</h4></p>\n";
        result += "<p><i>Создано "+DateFormatter.format(photo.getDate())+"</i></p>";
        result += "<p><a href=\"index.jsp?id="+photo.getParent().getKey()+"\"><img src=\"img/back.png\" alt=\"Назад\"/></a>\n";
        if (isOwn) {
            result += "<a href=\"album-processor.jsp?objid="+photo.getKey()+"&action=delete\"><img src=\"img/delete.png\" alt=\"Удалить\"/></a></p>";
        } else {
            result += "</p>";
        }
        result += "<p align=\"center\"><img src=\"photo.jsp?id="+photo.getKey()+"&view=full\"/></p>";
        return result;
    }
    public boolean isSide() {
        return false;
    }
}
